<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//注册和重置密码功能
Auth::routes(
    [
        'register'=>env('SETTING_REGISTER',false),
        'reset'=>env('SETTING_RESET_PASSWORD',false),
    ]);

Route::post('/logout','Auth\\LoginController@logout');

//入口路径
Route::get('/', 'HomeController@index')->name('home');
Route::get('/home', 'HomeController@index')->name('home');

// easywechat
Route::any('/wechat', 'WeChatController@serve');
//Route::group(['middleware' => ['web', 'wechat.oauth']], function () {
//    Route::get('/user', function () {
//        $user = session('wechat.oauth_user.default'); // 拿到授权用户资料
//
//        dd($user);
//    });
//});
//Route::group(['middleware' => ['wechat.oauth:snsapi_userinfo']], function () {
//    // ...
//});

Route::options('/{all}', function(\Illuminate\Http\Request $request) {
    $origin = $request->header('ORIGIN', '*');
    header("Access-Control-Allow-Origin: $origin");
    header("Access-Control-Allow-Credentials: true");
    header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE');
    header('Access-Control-Allow-Headers: Origin, Access-Control-Request-Headers, SERVER_NAME, Access-Control-Allow-Headers, cache-control, token, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie');
})->where(['all' => '([a-zA-Z0-9-]|/)+']);


// 查看日志需要登录
Route::middleware('auth')->group(function(){
    Route::get('logs', '\Rap2hpoutre\LaravelLogViewer\LogViewerController@index');
});
